function Nash_equilibrium_grid
    % ... (other functions and code)

    % Load Welfare_max from the saved file
    load Results_NN.mat

    welfare_max = [GFT1' GFT3' shock13(position(:,2))' shockchi31(position(:,3))' shockchi33(position(:,5))'];

    % Find Nash equilibrium using the provided function
    [eq1, eq2] = findNashEquilibrium(welfare_max);

    % Display the Nash equilibrium
    disp(['Nash Equilibrium: Country 1 - Instrument ' num2str(eq1)]);
    disp(['Nash Equilibrium: Country 2 - Instruments ' num2str(eq2)]);
end

function [eq1, eq2] = findNashEquilibrium(Welfare_max)
    % Extract instrument values and welfare for each country
    Instruments1 = Welfare_max(:, 3);
    Instruments2 = Welfare_max(:, 4:5);
    Welfare1 = Welfare_max(:, 1);
    Welfare2 = Welfare_max(:, 2);

    % Find the best response for country 1 given country 2's choice
    [~, idx1] = max(Welfare1(Instruments2(:, 1) == Instruments1));
    eq1 = Instruments1(idx1);

    % Find the best response for country 2 given country 1's choice
    valid_idx = find(Instruments2(:, 1) == eq1);
    [~, idx2] = max(Welfare2(valid_idx));
    eq2 = Instruments2(valid_idx(idx2), :);

 
        disp(['Nash Equilibrium: Country 1 - Instrument ' num2str(eq1)]);
         disp(['Nash Equilibrium: Country 2 - Instruments ' num2str(eq2)]);

end
